package com.itheima.Demo7;

import java.io.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;

public class Demo {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("day0731\\maths.txt"));

        ArrayList<String> list = new ArrayList<>();
        String s;
        while((s = br.readLine()) != null){
            if(s.contains("/")){
                String[] split = s.split("/");
                int i = Integer.parseInt(split[0]);
                int i1 = Integer.parseInt(split[1]);
                String s1 = (i + "/" + i1 + "=" + (i / i1));
                list.add(s1);
                System.out.println(s1);
            }else if(s.contains("*")){
                String[] split = s.split("\\*");
                int i = Integer.parseInt(split[0]);
                int i1 = Integer.parseInt(split[1]);
                String s1 = (i + "*" + i1 + "=" + (i * i1));
                list.add(s1);
                System.out.println(s1);
            }else if(s.contains("-")){
                String[] split = s.split("-");
                int i = Integer.parseInt(split[0]);
                int i1 = Integer.parseInt(split[1]);
                String s1 = (i + "-" + i1 + "=" + (i - i1));
                list.add(s1);
                System.out.println(s1);
            }else if(s.contains("+")){
                String[] split = s.split("\\+");
                int i = Integer.parseInt(split[0]);
                int i1 = Integer.parseInt(split[1]);
                String s1 = (i + "+" + i1 + "=" + (i + i1));
                list.add(s1);
                System.out.println(s1);
            }else{
                list.add(s);
                System.out.println(s);
            }
        }
        BufferedWriter bw = new BufferedWriter(new FileWriter("day0731\\maths.txt"));
        for (String s1 : list) {
            bw.write(s1);
            bw.newLine();
        }
        bw.close();
        br.close();
    }
}
